<?php

/**
 * @category   MM
 * @package    MM_Service
 */
class MM_Service_Admin_EventVenue extends Mediad2_Service_Abstract
{
	/**
	 * 初始化
	 */
	public function init()
	{
		$this->setMapper('MM_Mapper_EventVenue');
		$this->setModel('MM_Model_EventVenue');
	}
	
	/**
	 * 更新会议场所
	 * @param int $evid
	 * @param array $params
	 * @return Mediad2_Model_Result
	 */
	public function updateVenue($evid, array $params)
	{
		try {
			//获取指定id的event venue
			$result = $this->find($evid);
			if ($result->getCode()==$result::CODE_FAILURE) return $result;
			$model = $result->getData();
		
			//封装model
			if (isset($params['name'])) $model->setName($params['name']);
			if (isset($params['desc'])) $model->setDesc($params['desc']);
			if (isset($params['url'])) $model->setUrl($params['url']);
			if (isset($params['w'])) $model->setW($params['w']);
			if (isset($params['h'])) $model->setH($params['h']);
			if (isset($params['level'])) $model->setLevel($params['level']);
			
			return $this->update($model);
		
		} catch (Zend_Exception $e) {
			$this->handleException($e); //出错处理
			return $this->returnResult(Mediad2_Model_Result::CODE_FAILURE); //返回结果--失败
		}
	}
	
}